package com.guaoran.consul.services.consumer.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author : 孤傲然
 * @description : consumer
 * @date :2019/11/22 15:30
 */
@RestController
public class HelloController {
    @Autowired
    private RestTemplate restTemplate;

    @Value("${spring.cloud.provider.application.name}")
    private String providerName;

    @GetMapping("/hello")
    public String hello(){
        System.out.println("hello");
        return restTemplate.getForObject("http://"+providerName+"/hello",String.class);
    }
    @GetMapping("/word")
    public String word(){
        System.out.println("word");
        return restTemplate.getForObject("http://"+providerName+"/word",String.class);
    }
    @GetMapping("/message")
    public String message(String message){
        System.out.println("message");
        return restTemplate.getForObject("http://"+providerName+"/message?message="+message,String.class);
    }

}
